/*
 * @Author: 田鑫
 * @Date: 2023-03-05 18:14:17
 * @LastEditors: 田鑫
 * @LastEditTime: 2023-03-05 19:20:40
 * @Description: 
 */
import { createRouter, createWebHistory } from 'vue-router';
import { appRoutes } from './routes';
import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from './routes/base';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';

import createRouteGuard from './guard';

NProgress.configure({ showSpinner: false }); // NProgress Configuration

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/dashboard',
    },
    {
      path: '/dashboard',
      name: 'dashboard',
      redirect: '/dashboard/components/table',
      children: [...appRoutes, REDIRECT_MAIN, NOT_FOUND_ROUTE],
    },
    {
      path: '/permission',
      name: 'permission',
      component: () => import('@/views/components/permission/choose-enterprise.vue'),
    },
    {
      path: '/auth',
      name: 'auth',
      component: () => import('@/views/components/permission/auth.vue'),
    },
  ],
  scrollBehavior() {
    return { top: 0 };
  },
});

createRouteGuard(router);

export default router;
